#include"StepperPump.hpp"
#include "MiscUtils/TdrMisc/SEngine.h"
#include "../GRBLMaster/GRBLMaster.hpp"
#include "Comms/SerialPortManager/SerialPortManager.hpp"

using namespace std;

//GRBLMaster* SlaveNat(void* ptr) {
//	return (GRBLMaster*)ptr;
//};

#define SlaveNat ((GRBLMaster*)_misc.slave)
#define SlaveCommNat ((SerialPortManager*)(((GRBLMaster*)_misc.slave)->_core.slaveNativeHandle))
#define SlaveCommVoid ((GRBLMaster*)_misc.slave)->_core.slaveNativeHandle

// bookmark: slaves: pump: default parameters 
StepperPumpSlave::StepperPumpSlave(GeneralSlave* ref) {
	if (ref->_meta.controlFunctions.length() == 0) {
		TLogger::writeLine(L"No functions specified for " + ref->getReferenceName() + L" yet. Set default.");
		ref->_meta.defaultFunctions = L"pump(rep):dispense|aspirate";
	}
	if (ref->_meta.controlParameters.length() == 0) {
		TLogger::writeLine(L"No parameters specified for " + ref->getReferenceName() + L" yet. Set default.");
		ref->_meta.defaultParameters = L"unit_per_mm=1uL,channel_number=" + TWFormater::int2str(_motorAxis.maxAxisNum);
	}

	roboInit(ref);
	SlaveNat->_flags.simuAccMMPerSecSec = 1;
}

StepperPumpSlave::~StepperPumpSlave() {
	roboRelease();
}

//std::wstring StepperPumpSlave::getLimitedStr() {
//	return L"None";
//}

std::set<std::wstring> StepperPumpSlave::getAxialFuncs() {
	set<wstring> ret;

	ret.insert(L"pump");

	return ret;
}

void StepperPumpSlave::debug_testConfirm() {	
	SlaveNat->_state.parsedAxisNum = 0;
	_state.targetXYZABC[0] = 1;
	_state.targetXYZABC[1] = 0;

	int mask = 0b01;
	vector<float> position; position.push_back(1); position.push_back(2);
	int ret = confirmPosition(mask, position);
	int stop = 1;
}
